package com.pioneer.gui.invoice.controller;

import java.util.Vector;
import java.util.HashMap;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import com.pioneer.gui.invoice.util.InvoiceDAO;
import com.pioneer.gui.invoice.util.Constants;
import com.pioneer.gui.invoice.util.DropDownDataFactory;
import com.pioneer.gui.invoice.model.InvoiceModel;
import com.pioneer.gui.invoice.model.InvoiceTableModel;
import com.pioneer.gui.invoice.view.DetailsPanel;

public class DeleteRowButtonAdapter
implements ActionListener,Constants
{
	private InvoiceModel model;
	private DetailsPanel detailsSection;
	
	public DeleteRowButtonAdapter(InvoiceModel model,DetailsPanel detailsSection)
	{
		this.model=model;
		this.detailsSection=detailsSection;
	}
		
	public void actionPerformed(ActionEvent e)
	{
		InvoiceTableModel invoiceTableModel=this.model.getInvoiceDetails();
		int rowToDelete=detailsSection.getSelectedRow();
		if ((rowToDelete>=0)&&(invoiceTableModel.getRowCount()>=1))
			invoiceTableModel.deleteRow(rowToDelete);
		
	}		
}